Repository navigation
fix(resolve): stop binding calls, imports and supertypes to coincidences - #211
Merged
Merged
Conversation
A missing edge makes an agent look further; a false edge makes it confidently wrong. Three shapes produced false ones. Extraction discarded a member-shaped receiver, so `this.mailer.send(m)` reached resolution as the bare name `send`. With two same-named methods in one file the line-proximity term then scored the enclosing method +20.0 against the real target's +19.7, and a method resolved to ITSELF while the true callee went unreferenced. The receiver's last segment is now preserved, across TypeScript, Python, Go, Rust and Swift rather than TypeScript alone. Built-in receivers hijacked project methods. The inferred type is now required to be BOUND at the call site — declared in the same file, or carried by an import mapping — and the gate sits before typed resolution rather than after its failure, because the hijack arrives via a typed path that SUCCEEDS. No built-in name list is introduced; visibility is the discriminator. Inference additionally reads a class field's own declaration, which the enclosing-scope scan cannot reach, so a field receiver is typed instead of guessed. Import and supertype references bound to any local symbol sharing the name: an `imports` edge landed on a class property, and an out-of-repo supertype on an enum member. Both now require a target of a compatible kind AND locality, because kind filtering alone merely relocates the false edge onto a legally kinded type alias. Recursion is untouched: `self.run(n - 1)` is a genuine self-edge and the erlang golden's two remain. On this repo the change removes 111 `impl Drop for X` edges that had bound to a C++ enum member, leaving 21 that all target real in-repo traits, interfaces and modules, and upgrades 432 calls from a proximity guess to a receiver-typed binding. EXTRACTION_VERSION 5 -> 6: stored edges change, so an existing index is stale.
Codecov Report❌ Patch coverage is @@ Coverage Diff @@
## main #211 +/- ##
==========================================
+ Coverage 95.22% 95.27% +0.04%
==========================================
Files 137 137
Lines 73336 74430 +1094
==========================================
+ Hits 69836 70911 +1075
- Misses 3500 3519 +19
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tier 2 of the post-
v1.5.0upstream sync. A missing edge makes an agent look further; a false edge makes it confidently wrong. Three shapes produced false ones.Item 4 — a method resolved to itself (upstream #1496)
Extraction discarded a member-shaped receiver, so
this.mailer.send(m)arrived at resolution as the bare namesend. With two same-named methods in one file,find_best_match's line-proximity term then scored the enclosing method +20.0 against the real target's +19.7:Mailer.send@L1— the true target — got neither edge. The receiver's last segment is now preserved, and across TypeScript, Python, Go, Rust and Swift rather than TypeScript alone, since the plan's own admission was that only TS had been measured.Item 5 — built-in receivers hijacked project methods (#1566)
The first design placed its refusal after
resolve_method_on_typefailed. That was dead code: an unimported projectclass Mapbeside a built-in producesinstance-method 0.9— the typed path succeeds. The gate now precedes typed resolution and asks whether the inferred type is bound at the call site (same-file declaration, or an import mapping whoselocal_namematches). No built-in name list is introduced; visibility is the discriminator, so a project class legitimately namedMapstill resolves.Inference also now reads a class field's own declaration.
enclosing_scope_start_linefilters toFunction | Method, so a field above a method is unreachable from the backward scan — which left three residual self-edges after item 4 landed:Teaching inference to see the field beat refusing the fallback, because the field route already reached the correct target — it just guessed. Measured with competing candidates present:
const conn = new Backend()instance-method 0.9private conn = new Backend()exact-match 0.4instance-method 0.9Refusing would have deleted that correct edge; this upgrades it. The lookup reads the field node's own
start_linerather than widening the scan window, because the scan takes the nearest match above the call and a class-wide window would prefer a sibling method'sconst conn = new Wrong().Item 6 — phantom imports and fabricated supertypes (#1537/#1536)
An
importsedge landed on a class property sharing the imported name, and an out-of-repo supertype bound to a local enum member. Both now require a target of compatible kind and locality. Both gates are needed: kind filtering alone merely relocates the false edge onto a legally kindedtype_alias, which is why the fixture deliberately keeps an alias to catch a kind-only implementation.Recursion is untouched
self.run(n - 1)is a genuine self-edge;reference/golden/erlang/edges.json's two remain. A blanket self-exclusion rule would have deleted them and broken golden byte-stability — measured before designing, and the reason that obvious-looking fix was rejected.Effect on this repository's own index
implementsimpl Drop for Xbound to a C++ enum member; the surviving 21 all target real in-repo traits, interfaces and modules — verifiedcallsexact-match−743 againstinstance-method+432: 432 edges upgraded from a proximity guess to a receiver-typed binding, plus 13 removed self-edgesextendscontains,imports,instantiates,referencesextendsstaying at 8 is load-bearing. An intermediate version regressed it to 12: the new pre-ranking filter collapsed a 2-candidate set to 1, and the single-candidate shortcut skipsfind_best_match— and with it the cross-language penalty that had correctly sunk those scores, so GDScriptextends Nodenewly bound this repo's Ruststruct Node. Fixed by ranking over the filtered set, pinned by its own test. No unit or fixture test caught it — only the whole-repo diff did.Verification
make cigreen: 128 suites / 3214 passed / 0 failed (baseline 127 / 3172).git status --porcelain --untracked-files=all reference/empty; goldeninstance-methodtotal still 7 (cpp 4, mini 3); erlang's 2 recursion self-edges intact.EXTRACTION_VERSION5 → 6 exactly once — stored edges change, so an existing index is stale.crates/codegraph-resolve/tests/fixtures/tier2/, each consumed by an assertion; the acceptance battery fails onmainfor the stated reason and passes here, with controls (legitimate recursion, an imported class's real calls, an in-repouse) holding throughout.Declared residue, deliberately not fixed
getMap().get("a")still produces a false edge — item 4 rewrites only member-expression receivers, not the call-expression arm. The non-ESM class-field case persists too (Java/Kotlin have their own inferrers). Both are recorded as persisting-not-regressing rather than silently claimed fixed.All four upstream issues remain open and PR #1538 is unmerged, so item 6 ports a proposal; items 4 and 5 have no upstream implementation to compare against. The plan cleared five review rounds and ten blockers.